package cn.itcast.web.exceptions;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CustomExceptionResolver implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
        ModelAndView mv = new ModelAndView();
        //保存错误信息到域里面去
        mv.addObject("errorMsg" ,"系统错误，怪我咯");
        mv.addObject("err" ,e.getMessage());
        //设置跳转页面
        mv.setViewName("error");
        return mv;
    }
}
